package edu.udlap.spring2008.is300.finalexam.framework.mvc.observerobservable.imageset;

import java.util.ArrayList;
import java.util.Iterator;

/**
 *
 * @author Ruslán Ledesma Garza
 */

///this class allows for code reuse by means of object composition...
public class ImageSetChangedObservableHelper implements ImageSetChangedObservable
{
    
    ArrayList<ImageSetChangedListener> observers = new ArrayList<ImageSetChangedListener>();
    ImageSetChangedObservable observedObject;
    
    public ImageSetChangedObservableHelper(ImageSetChangedObservable observedObject)
    {
        this.observedObject = observedObject;
    }

    public void addImageSetChangedListener(ImageSetChangedListener observer)
    {
        observers.add(observer);
    }

    public void removeImageSetChangedListener(ImageSetChangedListener observer)
    {
        observers.remove(observer);
    }

    public void raiseImageSetChangedEvent(Object args)
    {
        Iterator<ImageSetChangedListener> i = observers.iterator();
        ImageSetChangedListener observer;
        while(i.hasNext())
        {
            observer = i.next();
            observer.imageSetChanged(observedObject, args);
        }
    }

}
